<?php
    include '../data/black_dal.php';
    include_once '../entity/black_entity.php';

    class BlackMng
    {
        function update($blackEntity)
        {
            $blackDAL = new BlackDAL();
            return $blackDAL->update(
                                     $blackEntity->id,
                                     $blackEntity->rfqID,
                                     $blackEntity->carbonContent,
                                     $blackEntity->particleSize,
                                     $blackEntity->filler,
                                     $blackEntity->carrier,
                                     $blackEntity->finalApp,
                                     $blackEntity->techRequirement,
                                     $blackEntity->qcRequirement,
                                     $blackEntity->contactRequirement,
                                     $blackEntity->ploymerMFI,
                                     $blackEntity->customerResin,
                                     $blackEntity->inTime,
                                     $blackEntity->inUser);
        }

        function get($id)
        {
            $where = "id = ". $id;
            $blackDAL = new BlackDAL();
            if ($result = $blackDAL->get($where)) {
                $row = $result->fetch_array();
            } else {
                return false;
            }
        }

        function getAll($start, $pageSize, $sortField, $sortDirection)
        {
            $orderBy = "ORDER BY " . $sortField . " " . $sortDirection . " LIMIT " . $start . ", " . ($pageSize * ($start + 1));
            $blackDAL = new BlackDAL();
            if ($result = $blackDAL->getAll($orderBy)) {
                while ($row = $result->fetch_array()) {
                    $blackList[] = $row;
                }
                return $blackList;
            } else {
                return false;
            }
        }

        function delete($id)
        {
            $blackDAL = new BlackDAL();
            return $blackDAL->delete($id);
        }
    }

?>
